package com.mall.b2c.domain.member;

import java.util.Date;

import javax.persistence.*;

import com.mall.b2c.domain.goods.GoodsDomain;
import com.mall.b2c.domain.order.OrderItemDomain;
import com.mall.common.domain.BaseEntity;

/**
 * 评论
 * 
 * @author wangzx
 */
@Entity
@Table(name = "b2c_comment")
public class CommentDomain extends BaseEntity {
	private static final long serialVersionUID = -4768778448553485583L; 
	private String userName;
	private Boolean anonymous;
	private String content;
	private Integer score;
	private String ip;
	private Date commentDate;
	private Boolean isDeleted;
	private String deletePerson;

	private MemberDomain member;
	private GoodsDomain goods;
	private OrderItemDomain orderItem;

	@PrePersist
	public void PrePersist(){
		if(isDeleted == null){
			isDeleted = false;
		}
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Boolean getAnonymous() {
		return anonymous;
	}

	public void setAnonymous(Boolean anonymous) {
		this.anonymous = anonymous;
	}
	
	@Column(columnDefinition="varchar(1024)")
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Integer getScore() {
		return score;
	}

	public void setScore(Integer score) {
		this.score = score;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public Date getCommentDate() {
		return commentDate;
	}

	public void setCommentDate(Date commentDate) {
		this.commentDate = commentDate;
	}

	public Boolean getIsDeleted() {
		return isDeleted;
	}

	public void setIsDeleted(Boolean isDeleted) {
		this.isDeleted = isDeleted;
	}

	public String getDeletePerson() {
		return deletePerson;
	}

	public void setDeletePerson(String deletePerson) {
		this.deletePerson = deletePerson;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "member_id")
	public MemberDomain getMember() {
		return member;
	}

	public void setMember(MemberDomain member) {
		this.member = member;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "goods_id")
	public GoodsDomain getGoods() {
		return goods;
	}

	public void setGoods(GoodsDomain goods) {
		this.goods = goods;
	}

	@OneToOne(fetch = FetchType.LAZY, mappedBy = "comment")
	public OrderItemDomain getOrderItem() {
		return orderItem;
	}

	public void setOrderItem(OrderItemDomain orderItem) {
		this.orderItem = orderItem;
	}
}